package edu.sctu.practice.class02.yangyuran.test12;

import java.util.Scanner;

/**
 * Created by Administrator on 2015/10/12.
 */
public class Cars {
    public int tires;
    public int carweight;
    public int load;
    public int speed;
    public String color;
    public String brand;

    public Cars(int tires, int carweight, int load, int speed) {
        this.tires = tires;
        this.carweight = carweight;
        this.load = load;
        this.speed = speed;
    }

    public Cars(String color, String brand) {
        this.color = color;
        this.brand = brand;
        System.out.println("汽车商标为：" + brand + "颜色为：" + color);
    }

    public void addSpeed() {
        System.out.println("初始速度为：" + this.speed);
        System.out.println("请输入要增加的速度（请不要超出正常速度）：");
        Scanner scan = new Scanner(System.in);
        int spee = scan.nextInt();
        int newspeed = this.speed + spee;
        System.out.println("增加后的速度为：" + newspeed);
    }

    public void cutSpeed() {
        System.out.println("初始速度为：" + this.speed);
        System.out.println("请输入要减少的速度（请不要使得速度小于零）：");
        Scanner scan = new Scanner(System.in);
        int spe = scan.nextInt();
        int newspeed01 = this.speed - spe;
        if (newspeed01 >= 0) {
            System.out.println("减少后的速度为：" + newspeed01);
        } else {
            System.out.println("汽车停车了。");
        }
    }

    public static void main(String[] args) {
        Cars car = new Cars("奔驰", "蓝色");
        Cars car01 = new Cars(4, 10, 5, 80);
        car01.addSpeed();
        car01.cutSpeed();
    }
}
